package org.act.xservices.rt.xcontainer.service.resolver;

import javax.xml.namespace.QName;

import org.act.xservices.rt.xcontainer.inf.context.IServiceContext;
import org.act.xservices.rt.xcontainer.inf.service.wsdl.XcOperation;
import org.act.xservices.rt.xcontainer.inf.service.wsdl.XcService;

public class SOAPBodyBasedOperationResolver extends AbstractOperationResolver {

	private final static String NAME = "SOAPBodyBasedOperationResolver";
	
	@Override
	protected void init() {
		this.name = NAME;
	}
	
	
	@Override
	public XcOperation findOperation(IServiceContext serviceContext)
			throws ResolverProcessException {
		
		XcService xcService = serviceContext.getXcService();
		
		QName reqMesQName = serviceContext.getInMessageBody().selectorElementName(".\\*");
		
		if( xcService != null && reqMesQName != null){
			
			return xcService.getXcOperation( new QName(reqMesQName.getLocalPart()) );
			
		}else{
			return null;
		}
	}
}
